package demo.single;

/**
 * @author wangql
 * 线程安全
 * 懒加载
 * 可以在多线程的情况下保持高性能
 */
public class 双检锁 {

    private volatile  static 双检锁 shuangJianSuo;

    private 双检锁 (){}

    public static 双检锁 getInstance() {
        if(shuangJianSuo == null) {
            synchronized (双检锁.class) {
                if(shuangJianSuo == null) {
                    shuangJianSuo = new 双检锁();
                }
            }
        }
        return shuangJianSuo;
    }
}
